﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ClientForm.ascx.cs"
    Inherits="Phong_CTSV.ClientForm" %>
<% 
    bool hasRowsHeader = formInfo.Has_rows;
%>
<div>
    <asp:Label ID="lbYear" runat="server" Text="Năm báo cáo:  " />
    <asp:DropDownList ID="ddlYear" runat="server" />
</div>
<div class="title">
    <h1>
        <% Response.Write(formInfo.Decription); %></h1>
</div>
<div class="table">
    <table class="clientForm">
        <thead>
            <tr>
                <%  int index = 0;
                    // PARENT COLUMN HEADER GENERATE
                    foreach (Phong_CTSV.Columns_Header ch in ColumnsHeaderList)
                    {
                        if (ch.Parent_id == 0)
                        {
                            int child = 0;
                            foreach (Phong_CTSV.Columns_Header childHeader in ColumnsHeaderList)
                            {
                                if (childHeader.Parent_id == ch.ID)
                                {
                                    child++;
                                }
                            }
                
                %>
                <td <%  if (child==0) {Response.Write("rowspan=2");} else {Response.Write("colspan="+child);} %>
                    class="<% if (index%2==0) { Response.Write("even");} else { Response.Write("odd");} %>">
                    <%Response.Write(ch.Name);%>
                </td>
                <%
index++;
                }
            }
                %>
            </tr>
            <tr>
                <%
                    index = 0;
                    //CHILD COLUMN HEADER
                    foreach (Phong_CTSV.Columns_Header ch in ColumnsHeaderList)
                    {
                        if (ch.Parent_id != 0)
                        {
                %>
                <td class="<% if (index%2==0) { Response.Write("sub-even"); } else { Response.Write("sub-odd");} %>">
                    <%Response.Write(ch.Name); %>
                </td>
                <%      
                    }//if
                index++;
            }
            //foreach
                %>
            </tr>
        </thead>
        <tbody>
            <%
        
                // ROW HEADER GENERATE
                int rowIndex = 0;
                foreach (Phong_CTSV.Rows_Header rh in RowsHeaderList)
                {
            %>
            <tr class="<% if (index%2==0) { Response.Write("even");} else { Response.Write("odd");} %>">
                <% if (hasRowsHeader)
                   { %>
                <td>
                    <%Response.Write(rh.Name);%>
                </td>
                <%} //if

                   for (int i = 0; i < NumColumn; i++)
                   {
                %>
                <td>
                    <input id="<%Response.Write(DataTable[rowIndex, i].Code_name); %>" name="<%Response.Write(DataTable[rowIndex, i].Code_name); %>"
                        class="cell" type="text" value="<%Response.Write(DataTable[rowIndex, i].Value); %>" />
                </td>
                <%
               
                    }
                %>
            </tr>
            <%
                rowIndex++;
                index++;
        } if (IsSum)
        { //foreach
            %>
            <tr>
                <td>
                    TỔNG
                </td>
                <%foreach (var item in SumValue)
                  {%>
                <td>
                    <input class="cell" type="text" readonly="readonly" value="<%Response.Write(item.Value); %>" />
                </td>
                <%} %>
            </tr>
            <%} %>
        </tbody>
    </table>
</div>
<asp:Button ID="Submit" runat="server" CssClass="button" OnClick="Submit_Click" Text="Hoàn Tất"
    Width="130px" />
<asp:Button ID="Button1" runat="server" OnClick="Download" Text="Tải về" Width="130px"
    CssClass="button" />
